// Learn cc.Class:
//  - https://docs.cocos.com/creator/manual/en/scripting/class.html
// Learn Attribute:
//  - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
//  - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html

cc.Class({
    extends: cc.Component,

    
    properties: {
        storyString: {
             type: cc.RichText,
             default: null
        },
        
        tips: {
             type: cc.Label,
             default: null
        },
     },
 
      onLoad () {
          
         this.story = window._GAMESTORY['start'].split("");
          
         this.storyString.string = "";
          
         var j = 0;
         var interval = 0.1;// 以1秒为单位的时间间隔
         var repeat = this.story.length - 1;// 重复次数 = 字符串长度 - 1
         var delay = 0.1;// 我们在1秒后开始运行
         
         this.schedule(function() {
             this.storyString.string += this.story[j];
             j++;
         }, interval, repeat, delay);
          
         this.tips.node.runAction(cc.repeatForever(cc.sequence([cc.fadeOut(1),cc.fadeIn(1)])));
          
         this.node.on(cc.Node.EventType.TOUCH_END, function(){
             
             //delete window.gameData;
         
             this.storyString.node.runAction(cc.fadeOut(2));
             
             this.tips.node.active = false;
         
             window._JUMPSENCE = "chessFight";
             
             cc.director.loadScene('jump');
             
         }, this);
     },

});
